| Total Complexity | 2 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Controller, Inject, UseGuards, Get, Param, NotFoundException } from '@nestjs/common'; |
||
| 11 | |||
| 12 | @Controller('schools') |
||
| 13 | @ApiTags('School shooting') |
||
| 14 | @ApiBearerAuth() |
||
| 15 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 16 | export class GetSchoolShootingsAction { |
||
| 17 | constructor( |
||
| 18 | @Inject('IQueryBus') |
||
| 19 | private readonly queryBus: IQueryBus |
||
| 20 | ) {} |
||
| 21 | |||
| 22 | @Get(':id/shootings') |
||
| 23 | @Roles(UserRole.PHOTOGRAPHER) |
||
| 24 | @ApiOperation({ summary: 'Get school shootings' }) |
||
| 25 | public async index(@Param() dto: IdDTO): Promise<ShootingSummaryView[]> { |
||
| 26 | try { |
||
| 27 | return await this.queryBus.execute(new GetShootingsBySchoolQuery(dto.id)); |
||
| 28 | } catch (e) { |
||
| 29 | throw new NotFoundException(e.message); |
||
| 30 | } |
||
| 33 |